﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BrightIdeasSoftware;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace Managistics.Warehouse.Views.Controls
{
    public class IndexRenderer : BaseRenderer
    {
        public IndexRenderer() : base()
        {
            object obj = this;
        }
        public override bool OptionalRender(Graphics g, Rectangle r)
        {
            if (this.ListView.View != System.Windows.Forms.View.Tile)
                return false;

            using (LinearGradientBrush gradient = new LinearGradientBrush(r, Color.Gold, Color.Fuchsia, 0.0))
            {
                g.FillRectangle(gradient, r);
            }
            g.DrawRectangle(Pens.Black, r);

            StringFormat fmt = new StringFormat(StringFormatFlags.NoWrap);
            fmt.LineAlignment = StringAlignment.Center;
            fmt.Trimming = StringTrimming.EllipsisCharacter;
            fmt.Alignment = StringAlignment.Near;
            g.DrawString(this.GetText(), this.ListView.Font, Brushes.Black, r, fmt);

            return true;
        }

        public override void Render(Graphics g, Rectangle r)
        {
            using (LinearGradientBrush gradient = new LinearGradientBrush(r, Color.Gold, Color.Fuchsia, 0.0))
            {
                g.FillRectangle(gradient, r);
            }
            StringFormat fmt = new StringFormat(StringFormatFlags.NoWrap);
            fmt.LineAlignment = StringAlignment.Center;
            fmt.Trimming = StringTrimming.EllipsisCharacter;
            
            g.DrawString(this.GetText(), this.ListView.Font, Brushes.Black, r, fmt);
        }
    }
}
